package com.hsc.www.confimAndReturn;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.Connection;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserSender1 {
    @Autowired
    private RabbitTemplate template;
    @Autowired
    private CachingConnectionFactory cachingConnectionFactory;


    public void send()  throws Exception{

        template.setConfirmCallback((correlationData,  ack,  cause)->{
            System.out.println(ack);
            System.out.println("ddddd");
        });

       template.convertAndSend("", "abc", "UserSender1");
        Connection connection = cachingConnectionFactory.createConnection();

        Channel channel=connection.createChannel(true);

    }
}